<?php
 include "counter.php";
 $placeid = $counter->get_input('placeid', '', 'get');
 $email = $counter->get_input('email', '', 'get');

pagestart();?>
<HTML>
<?php pagehead("Lost emails") ?>
<BODY>
<?php pagetop("Lost people") ?>
The list of people below do not have any valid email address by which they
can be contacted any more.
<p>
<?php
  if ($placeid) {
     $placeidpart = "and persons.placeid like '$placeid%'";
     echo "This is the first 100 of the";
     echo "entries within \"$placeid\"";
  } else if ($email) {
     echo "TEST email";
     $placeidpart = "and email.f_key like '$email%'";
  } else {
     echo "This is the first 100 of the ";
     echo dbcount('email', "email.usage = 'main' and email.state = 'bad'");
     echo " entries";
     $placeidpart = "";
  }
?>
 with known bad reply-to.
<p>
To limit to a specific geographical area,  type its ID here.
<form action="<?php echo $SCRIPT_NAME?>">
ID: <input name="placeid" value="<?php echo $placeid?>"><br>
Email: <input name="email" value="<?php echo $email?>"><br>
<input type=submit value="Go!">
</form>
<table class="info" border>
<tr><th>Key<th>Email<th>Name<th>Error
<?php
  $query = mysql_query("select persons.f_key, email.f_key, persons.name, email.error from persons, email where persons.f_key = email.owner and email.state = 'bad' and email.usage = 'main' $placeidpart order by email.f_key limit 100");

  while ($arr = mysql_fetch_row($query)) {
	$arr[0] = htmlspecialchars($arr[0]);
	echo "<tr><td>";
	echo "<a href=\"/cgi-bin/adm/display-person.cgi?user=$arr[0]\">$arr[0]</a>";
	echo "<td>" . htmlspecialchars($arr[1]);
	echo "<td>" . htmlspecialchars($arr[2]);
	echo "<td>" . htmlspecialchars($arr[3]);
	echo "<td>" . htmlspecialchars($arr[4]);
 }
?>
</table>
<?php pagebottom() ?>
</body>
</html>
